package com.fastjrun.apiworld.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;
@Getter
@Setter
@ToString
public class PageResult<T> implements Serializable {
  public static final int PAGE_SIZE_DEFAULT = 20;
  private int total;
  private int pageSize;
  private int totalPage;

  @JsonProperty("currentPage")
  private int currPage;

  private List<T> rows;

  public PageResult() {}

  public PageResult(List<T> rows, int total, int pageSize, int currPage) {
    this.rows = rows;
    this.total = total;
    this.pageSize = pageSize;
    this.currPage = currPage;
    this.totalPage = (int) Math.ceil((double) total / (double) pageSize);
  }
}
